//
//  JieXiaoDetailFooter.m
//  HappyEat
//
//  Created by ctx2016 on 17/1/20.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

#import "JieXiaoDetailFooter.h"

@interface JieXiaoDetailFooter ()

@property (nonatomic,strong)UIImageView *iconView;

@property (nonatomic,strong)UILabel *noticeLabel;

//@property (weak, nonatomic) UIActivityIndicatorView *loading;

@end

@implementation JieXiaoDetailFooter

#pragma mark - 重写方法
#pragma mark 在这里做一些初始化配置（比如添加子控件）
- (void)prepare
{
    [super prepare];
    
    // 设置控件的高度
    self.mj_h = 40;
    
    // 添加label
    UILabel *label = [[UILabel alloc] init];
    label.textColor = [UIColor colorWithRed:108/255.0 green:108/255.0 blue:108/255.0 alpha:1.0];
    label.font = [UIFont boldSystemFontOfSize:16];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
    self.noticeLabel = label;
    
    // loading
//    UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
//    [self addSubview:loading];
//    self.loading = loading;
}

#pragma mark 在这里设置子控件的位置和尺寸
- (void)placeSubviews
{
    [super placeSubviews];
    
    self.noticeLabel.frame = self.bounds;
    
//    self.loading.center = CGPointMake(self.mj_w - 30, self.mj_h * 0.5);
}

#pragma mark 监听scrollView的contentOffset改变
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
{
    [super scrollViewContentOffsetDidChange:change];
    
}

#pragma mark 监听scrollView的contentSize改变
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change
{
    [super scrollViewContentSizeDidChange:change];
    
}

#pragma mark 监听scrollView的拖拽状态改变
- (void)scrollViewPanStateDidChange:(NSDictionary *)change
{
    [super scrollViewPanStateDidChange:change];
    
}

#pragma mark 监听控件的刷新状态
- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState;
    
    switch (state) {
        case MJRefreshStateIdle:
//            [self.loading stopAnimating];
//            [self.s setOn:NO animated:YES];
            self.noticeLabel.text = @"上拉查看图文详情（建议wifi下查看）";
            break;
        case MJRefreshStatePulling:
            self.noticeLabel.text = @"到底了，快放下来吧!";
            break;
        case MJRefreshStateRefreshing:
            self.noticeLabel.text = @"加载数据中";
            break;
        case MJRefreshStateNoMoreData:
            self.noticeLabel.text = @"木有数据了";
        default:
            break;
    }
}

#pragma mark 监听拖拽比例（控件被拖出来的比例）
- (void)setPullingPercent:(CGFloat)pullingPercent
{
    [super setPullingPercent:pullingPercent];
    
    // 1.0 0.5 0.0
    // 0.5 0.0 0.5
    CGFloat red = 1.0 - pullingPercent * 0.5;
    CGFloat green = 0.5 - 0.5 * pullingPercent;
    CGFloat blue = 0.5 * pullingPercent;
    self.noticeLabel.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
}

@end
